import { Controller,Get,Post,Body,Param ,ParseIntPipe,UseGuards,UseInterceptors} from '@nestjs/common';
import {UserService} from './user.service'
import {AuthGuard} from 'src/guard/auth.guard'
import {LoggingInterceptor} from 'src/interceptors/logging.interceptor'
//控制器中使用守卫
// @UseGuards(AuthGuard)
@Controller('user')
//控制器中使用拦截器
// @UseInterceptors(LoggingInterceptor)
export class UserController {
  constructor(
     private readonly userService:UserService
  ){}
  // 接口中使用守卫
  // @UseGuards(AuthGuard)
  @Get('/userById/:id')
  //接口中使用拦截器
  @UseInterceptors(LoggingInterceptor)
  async userById(
    @Param('id',new ParseIntPipe()) id:number
  ){
  return await this.userService.userById(id)     
  }
}
